package com.szy.web.model;
import java.util.List;

public class Page {
	private int currentPage;
	private int totalRecords;
	private int pageSize;
	private List list;//把查出来的实体类放到了list里面。类型随便你定。
	private int totalPage;
	
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public int getTotalPage() {
		return (totalRecords + pageSize - 1) / pageSize;
	}

	public int getFirstPage() {
		return 1;
	}

	public int getPreviousPage() {
		return currentPage <= 1 ? 1 : currentPage - 1;
	}

	public int getNextPage() {
		if (currentPage >= getTotalPage()) {
			return getLastPage();
		}
		return currentPage + 1;
	}

	public int getLastPage() {
		return getTotalPage() <= 0 ? 1 : getTotalPage();
	}
}
